package org.wlldTest.lesson2;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

import org.dromara.easyai.pso.PSO;

public class Test {
    public static void main(String[] args) throws Exception {
        // 1,2,3,4,5 , |1- 3|+|2-3|+..|5-3|/5 无限靠近在一个指定范围内随机生成的数值
        float[] minBorder = new float[]{1, 1, 1, 1, 1};
        float[] maxBorder = new float[]{40, 40, 40, 40, 40};
        Random random = new Random();
        int n = random.nextInt(20);//宝藏是 距离n最小的分配方案 假设n=5
        MyPosFunction myPosFunction = new MyPosFunction(n);
        PSO pso = new PSO(5, minBorder, maxBorder, 400, 200, myPosFunction
                , 0.5f, 2, 2, false, 10, 1);
        pso.start();
        float[] best = pso.getAllBest();
        float sigma = myPosFunction.sigma(best);
        float sub = myPosFunction.getResult(best, 0);
        System.out.println("所有人拿到金额的和:" + sigma);
        System.out.println("与指定目标的平均差:" + sub + ",我们指定目标的平均差的值:" + n);
        System.out.println(Arrays.toString(best));
    }
}
